package com.rd.student.dashuju.wangbo.examination;

import java.io.*;
import java.util.Scanner;

public class Student {

   String name;
   int scoreChinese;
   int scoreMath;

    public Student(String name, int scoreChinese, int scoreMath) {
        this.name = name;
        this.scoreChinese = scoreChinese;
        this.scoreMath = scoreMath;
    }

    @Override
    public String toString() {
        return  name + " " +
               " " + scoreChinese +
                " " + scoreMath +
                " " + (scoreChinese+scoreMath) ;
    }

    public static void main(String[] args) throws Exception{

        File file = new File("Student.txt");
        Writer writer = new FileWriter(file);
        BufferedWriter bw = new BufferedWriter(writer);
        String s = "姓名 语文成绩 数学成绩 总分";
        bw.write(s);
        bw.newLine();

        for (int i = 0; i < 3; i++) {
            Scanner scanner = new Scanner(System.in);
            System.out.println("请输入姓名：");
            String name = scanner.nextLine();
            System.out.println("请输入语文成绩：");
            int scoreChinese = scanner.nextInt();
            System.out.println("请输入数学成绩：");
            int scoreMath = scanner.nextInt();
            Student student = new Student(name,scoreChinese,scoreMath);
            bw.write(student.toString());
            bw.newLine();
        }
        bw.close();
    }
}
